package tcln.sors.model.contact.dom;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

import tcln.sors.model.base.dom.AbstractSorsNamedEntity;

/**
 * Abstract entity for a contact.
 * 
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
@Entity
@Table(name = "TBL_CONTACT")
@AttributeOverrides({ @AttributeOverride(name = "id", column = @Column(name = "CONTACT_ID")) })
public class Contact extends AbstractSorsNamedEntity {
    private static final long serialVersionUID = 1L;

    /**
     * Contact type which defines if this contact is a customer or a vendor.
     */
    private ContactType type = ContactType.CUSTOMER;

    /**
     * Contact scope (enterprise or individual).
     */
    private ContactScope scope = ContactScope.ENTERPRISE;
    
    /**
     * The main contact address.
     */
    private String address1;
    
    /**
     * The secondary contact address.
     */
    private String address2;
    
    /**
     * The main phone number.
     */
    private String phone1;
    
    /**
     * The secondary phone number.
     */
    private String phone2;
    
    /**
     * Mobile phone number.
     */
    private String mobilePhone;
    
    /**
     * Fax.
     */
    private String fax;
    
    /**
     * The main email address.
     */
    private String email1;
    
    /**
     * The secondary email address.
     */
    private String email2;

    /**
     * Returns current value of {@link #type}.
     * 
     * @return the {@link #type}.
     */
    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "CONTACT_TYPE")
    public ContactType getType() {
        return type;
    }

    /**
     * Sets new value for {@link #type}.
     * 
     * @param type
     *            the new type to set
     */
    public void setType(ContactType type) {
        this.type = type;
    }

    /**
     * Returns current value of {@link #scope}.
     * 
     * @return the {@link #scope}.
     */
    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(name = "CONTACT_SCOPE")
    public ContactScope getScope() {
        return scope;
    }

    /**
     * Sets new value for {@link #scope}.
     * 
     * @param scope
     *            the new scope to set
     */
    public void setScope(ContactScope scope) {
        this.scope = scope;
    }

    /**
     * Returns current value of {@link #address1}.
     * 
     * @return the {@link #address1}.
     */
    @NotNull
    @Length(max = 300)
    @Column(name = "ADDRESS_1")
    public String getAddress1() {
        return address1;
    }

    /**
     * Sets new value for {@link #address1}.
     * 
     * @param address1
     *            the new address1 to set
     */
    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    /**
     * Returns current value of {@link #address2}.
     * 
     * @return the {@link #address2}.
     */
    @Length(max = 300)
    @Column(name = "ADDRESS_2")
    public String getAddress2() {
        return address2;
    }

    /**
     * Sets new value for {@link #address2}.
     * 
     * @param address2
     *            the new address2 to set
     */
    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    /**
     * Returns current value of {@link #phone1}.
     * 
     * @return the {@link #phone1}.
     */
    @Length(max = 20)
    @Column(name = "PHONE_1")
    public String getPhone1() {
        return phone1;
    }

    /**
     * Sets new value for {@link #phone1}.
     * 
     * @param phone1
     *            the new phone1 to set
     */
    public void setPhone1(String phone1) {
        this.phone1 = phone1;
    }

    /**
     * Returns current value of {@link #phone2}.
     * 
     * @return the {@link #phone2}.
     */
    @Length(max = 20)
    @Column(name = "PHONE_2")
    public String getPhone2() {
        return phone2;
    }

    /**
     * Sets new value for {@link #phone2}.
     * 
     * @param phone2
     *            the new phone2 to set
     */
    public void setPhone2(String phone2) {
        this.phone2 = phone2;
    }

    /**
     * Returns current value of {@link #mobilePhone}.
     * 
     * @return the {@link #mobilePhone}.
     */
    @Length(max = 20)
    @Column(name = "MOBILE")
    public String getMobilePhone() {
        return mobilePhone;
    }

    /**
     * Sets new value for {@link #mobilePhone}.
     * 
     * @param mobilePhone
     *            the new mobilePhone to set
     */
    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    /**
     * Returns current value of {@link #fax}.
     * 
     * @return the {@link #fax}.
     */
    @Length(max = 20)
    @Column(name = "FAX")
    public String getFax() {
        return fax;
    }

    /**
     * Sets new value for {@link #fax}.
     * 
     * @param fax
     *            the new fax to set
     */
    public void setFax(String fax) {
        this.fax = fax;
    }

    /**
     * Returns current value of {@link #email1}.
     * 
     * @return the {@link #email1}.
     */
    @NotNull
    @Length(max = 100)
    @Column(name = "EMAIL_ADDRESS_1")
    public String getEmail1() {
        return email1;
    }

    /**
     * Sets new value for {@link #email1}.
     * 
     * @param email1
     *            the new email1 to set
     */
    public void setEmail1(String email1) {
        this.email1 = email1;
    }

    /**
     * Returns current value of {@link #email2}.
     * 
     * @return the {@link #email2}.
     */
    @Length(max = 100)
    @Column(name = "EMAIL_ADDRESS_2")
    public String getEmail2() {
        return email2;
    }

    /**
     * Sets new value for {@link #email2}.
     * 
     * @param email2
     *            the new email2 to set
     */
    public void setEmail2(String email2) {
        this.email2 = email2;
    }
}
